// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
    env: "cloud1-0g0pppwwd5f51eb2",
    traceUser: true,
})

// 云函数入口函数

// 云函数入口函数 图片下载和鉴别
exports.main = async(event, context) => {
  console.log(event.fileID)
    const fileID = event.fileID
    const res = await cloud.downloadFile({
      fileID: fileID,
    })
    const buffer = res.fileContent
    try {
      var result = await cloud.openapi.security.imgSecCheck({
        media: {
          contentType: event.contentType,
          value: buffer
        }
      });
      return result
    } catch (err) {
      return err
    }
  }